#include <iostream>
#include <stdio.h>

using namespace std;

int k,n,minn= 1e9,s;
int vis[30];
int c[30][30];

void dfs(int step){
    if(step == n+1){
        if(s < minn){
            minn = s;
            return;
        }
    }
    if(minn < s){
            return;
        }
    for(int i = 1;i <= n ; i++){
        
        if(vis[i] == 0){
            vis[i] = 1;
            s +=c[i][step];
            dfs(step+1);
            vis[i] = 0;
            s-=c[i][step];
        }
    }
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin >> c[i][j];
        }
    }
    dfs(1);
    printf("%d",minn);
    return 0;
}